﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QueueTest
{
    class Program
    {
        static void Main(string[] args)
        {

            ArrayList arrayList = new ArrayList() { "昨天", "今天", "后天" };

            Queue queue = new Queue(arrayList);//队列

            queue.Enqueue("大后天");

            int[] array = { 1, 2, 3, 4 };

            queue.Enqueue(array);

            //直接遍历法
            OutValues(queue);


            Console.WriteLine("-------------");

            //GetEnumerator循环遍历枚举值法
            IEnumerator en = queue.GetEnumerator();

            while (en.MoveNext())
            {
                Console.WriteLine(en.Current);
            }



            //Dequeue移除遍历法
            while (queue.Count != 0)
            {
                Console.WriteLine("随着时光的流逝，{0}过去了", queue.Dequeue());
            }


            Console.ReadKey();
        }

        static void OutValues(ICollection collection)
        {
            foreach (var item in collection)
            {
                Console.WriteLine(item);
            }
        }
    }
}
